package pt.isel.pdm.yamba;

import java.util.LinkedList;
import java.util.List;
import winterwell.jtwitter.Twitter;
import android.content.Intent;
import android.graphics.Bitmap;
import android.util.Log;

public class Global{
	public static TimelineActivity timelineActivity;
	public static Intent timelinePullService;
	public static Object timelinePullWait = new Object();
	public static List<Post> elems = new LinkedList<Post>();
	private static Twitter _twitter;
	private static final Object _twittterLock = new Object();
	public static String username;
	public static String password;
	public static String apiuri;
	public static int msgstoshow;
	public static int msgskept;
	public static boolean autotlpull;
	public static int pullInterval; // IN SECONDS
	
	public static String name;
	public static Bitmap image;
	public static int followers;
	public static int following;
	public static int statuses;
	
	public static Twitter getTwitter(){
		synchronized(_twittterLock){
			if(_twitter == null){
				try{
					_twitter = new Twitter(Global.username, Global.password);
					_twitter.setAPIRootUrl(Global.apiuri);
				}catch(Exception e){
					Log.d("PDM", e.getMessage());
				}
			}
		}
		return _twitter;
	}
	public static void resetTwitter(){
		synchronized(_twittterLock){
			_twitter = null;
		}
	}
	
}
